singly linked is a data structure for storing and retrieving values in a linear sequence of storage locations called nodes. A singly linked list can be seen as an extension of a sequence or array. The main difference between the two is that elements in sequences may contain other sequences in them whereas each element in a single-linked list contains exactly one value.
Singly-linked lists are a simple data structure that can be used to build more complex data structures like trees and graphs with greater efficiency.
In programming, singly linked lists are widely used in software libraries and especially as the fundamental data structure for data structures used in functional languages such as Lisp, Scheme, Haskell, Erlang, or Ocaml. Linked lists have been one of the first invented data structures by Alonzo Church when he first published his paper on "An Unsolvable Problem" in 1936. The paper shows an algorithm for effectively implementing a singly linked list.
The basic list structure contains four components: a reference (i.e. the "link" to the next node), a value (or data), a link to the previous element, and a link to the next element. The following is an example of a singly linked list in pseudocode:
In this example, Node refers to any data structure that contains all the necessary fields. The next and previous fields are references (pointers) to the next and previous nodes in the list. The value field contains the data or information that is stored in the node. The value of a particular element is specified by setting its value field.
Nodes are linked together in a linear order. Each node will contain a reference to its next element, its data, a reference to its prev element, and an "infinity" link that points back to where it came from (its parent).
Creating a node of a single linked list
Self referential structure
This a structure that coantiains a pointer to a structure of the same type
Ex.
Struct abc{
Int a;
Char b;
Struct abc *self;
};
We will use a self refrnatial structure for creating a node of the single linked list
Node reprenataion in c
Data. Link
Struct node {
Int data;
Struct node *link;
}
We will call this structure as struct node,which consists of two different types.
The first is integer data it could be any data and the data type doesn't matter.
It could be a char float or any other data types
The second one is struct node star link. This link is the pointer to some other node and node is nothing but a structure only.
A node is nothing but a self refrnatial structure in c programming.
Comments
Post a Comment